# ！ /usr/bin/python3
# -*- coding:utf-8 -*-
# @Author:Peng Cao
# @File: utils.py
# @Software: PyCharm
import yaml
import jsonpath
import os

BATH_ROOT = os.path.dirname(__file__)


def red_config(expr):
    """
    读取config.yaml中的值
    :return:
    """
    file_path = os.path.join(BATH_ROOT, "config.yaml")
    with open(file_path, mode="r", encoding="utf-8") as f:
        config_dict = yaml.load(f.read(), Loader=yaml.FullLoader)
    value = jsonpath.jsonpath(config_dict, expr)[0]
    return value


if __name__ == '__main__':
    print(BATH_ROOT)
    val = red_config("$..log")
    print(val)
